package c_list;


import java.util.LinkedList;
import java.util.Queue;

//LinkedList作为Queue的实现类
public class QueueDemo01 {
    public static void main(String[] args) {
        Queue<String> qu = new LinkedList<>();
        //向集合中尾部添加元素
        qu.offer("tom");
        qu.offer("marry");
        qu.offer("jack");
        qu.offer("rose");
        System.out.println(qu);//[tom, marry, jack, rose]

        //从队列头部获取元素 -队列不变
        String s1 = qu.peek();
        System.out.println(s1);//tom
        System.out.println(qu);//[tom, marry, jack, rose]

        //从队列头部获取元素 - 出队列
        String s2 = qu.poll();
        System.out.println(s2);//tom
        System.out.println(qu);//[marry, jack, rose]

    }
}
